<template>
	<div class="module-item">
		<!-- <h2 v-if="title">{{ title }}</h2> -->
		<div class="module-title">
			<img src="../../assets/images/star.png" />
			<span v-if="title">{{ title }}</span>
		</div>
		<a-spin wrapperClassName="spinning" :spinning="loading" style="flex: 1">
			<slot style="display: flex; flex-direction: column; justify-content: center; background: #523d35" />
			<template #indicator>
				<div class="circle-3"></div>
			</template>
		</a-spin>
	</div>
</template>

<script setup lang="ts">
defineProps({
	title: {
		type: String,
		default: ''
	},
	loading: {
		type: Boolean,
		default: false
	}
});
</script>

<style lang="scss" scoped>
@keyframes rotation {
	0% {
		transform: rotate(0deg);
	}

	100% {
		transform: rotate(360deg);
	}
}

@keyframes rotation-back {
	0% {
		transform: rotate(0deg);
	}

	100% {
		transform: rotate(-360deg);
	}
}

.module-item {
	position: relative;
	z-index: 3;
	height: 100%;
	border-radius: 2vw;
	display: flex;
	flex-direction: column;
	.module-title {
		width: 100%;
		height: 43px;
		background-image: url('@/assets/images/moduleItem.png');
		background-repeat: no-repeat;
		padding: 0.1vw 1.5vw;
		font-weight: bold;
		color: #ffffff;
		text-align: center;
		white-space: nowrap;
		display: flex;
		align-items: center;
		img {
			width: 26px;
			height: 26px;
			margin-right: 8px;
		}
		span {
			font-size: 20px;
			font-weight: 400;
			color: #fff6d1;
			line-height: 104px;
		}
	}

	.spinning {
		flex: 1;
		padding: 10px 20px;
		background: rgba(82, 61, 53, 0.2);
		:deep(.ant-spin-blur) {
			height: 100%;

			&::after {
				border-radius: 20px;
			}
		}

		:deep(.ant-spin) {
			max-height: unset;
		}

		:deep(.ant-spin-container) {
			height: 100%;
			overflow: hidden;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
		}
	}
}

.circle-3 {
	position: relative;
	width: 60px;
	height: 60px;
	margin-top: -30px !important;
	margin-left: -30px !important;
	border: 3px solid;
	border-color: #ffffff #ffffff transparent transparent;
	border-radius: 50%;
	animation: rotation 1s linear infinite;
}

.circle-3::after,
.circle-3::before {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	margin: auto;
	content: '';
	border: 3px solid;
	border-radius: 50%;
	animation: rotation-back 0.5s linear infinite;
}

.circle-3::after {
	width: 52px;
	height: 52px;
	border-color: transparent #f5b251 #f5b251 transparent;
}

.circle-3::before {
	width: 44px;
	height: 44px;
	border-color: transparent transparent #ffffff #ffffff;
}
</style>
